package org.example.controller.admin;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.example.entity.Dizhi;
import org.example.result.Result;
import org.example.service.DizhiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/jibexinxi")
@Slf4j
@Api(tags = "用户基本信息相关接口")
public class EmployeedizhiControler {

    @Autowired
    DizhiService dizhiService;
    /**
     * 查询地址
     * @return
     */
    @GetMapping("/cxdizhi")
    @ApiOperation(value = "查询地址")
    public Result<List<Dizhi>> cxdizhi(@RequestParam( "username") String username) {

        log.info("查询地址：{}", username);
        return Result.success(dizhiService.cx(username));
    }

    /**
     * 新增地址
     * @return
     */
    @PostMapping("/xzdizhi")
    @ApiOperation(value = "新增地址")
    public Result<Integer> xzdizhi(@RequestBody Dizhi dizhi) {

        log.info("新增地址：{}", dizhi);
        return Result.success(dizhiService.xz(dizhi));
    }


    /**
     * 删除地址
     * @return
     */
    @DeleteMapping("/scdizhi")
    @ApiOperation(value = "删除地址")
    public Result scdizhi(@RequestParam( "username") String username, @RequestParam( "id") int id) {

        log.info("查询地址：{},{}", username,id);
        dizhiService.sc(username,id);
        return Result.success();
    }

}
